package com.doerit.laptops.action;

import org.springframework.beans.factory.annotation.Autowired;

import com.doerit.laptops.entity.Staff;
import com.doerit.laptops.service.StaffService;


public class HomeAction extends AbstractManagementAction {

	private static final long serialVersionUID = 1L;

	private int irisUserCount;
	private int userGroupCount;
	private int doorCount;
	private int systemUserCount;

	private Staff lastLogin;

	@Autowired
	private StaffService staffService;

	public String view() {

		setStaffCount(staffService.getCount());

		lastLogin = staffService.findLastLogin();
		if (isLogin()) {
			staffService.update(getSessionUserVariable());
			return SUCCESS;
		} else {
			return ERROR;
		}

	}

	public int getIrisUserCount() {
		return irisUserCount;
	}

	public void setIrisUserCount(int irisUserCount) {
		this.irisUserCount = irisUserCount;
	}

	public int getUserGroupCount() {
		return userGroupCount;
	}

	public void setUserGroupCount(int userGroupCount) {
		this.userGroupCount = userGroupCount;
	}

	public int getDoorCount() {
		return doorCount;
	}

	public void setDoorCount(int doorCount) {
		this.doorCount = doorCount;
	}

	public int getStaffCount() {
		return systemUserCount;
	}

	public void setStaffCount(int systemUserCount) {
		this.systemUserCount = systemUserCount;
	}

	public Staff getLastLogin() {
		return lastLogin;
	}

	public void setLastLogin(Staff lastLogin) {
		this.lastLogin = lastLogin;
	}

}
